package com.xuzimian.global.demo.spring.security.oauth2.client.config;


import org.springframework.security.oauth2.client.filter.OAuth2ClientContextFilter;
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;

import javax.servlet.Filter;
import javax.servlet.ServletContext;

/**
 * 该类会实现了WebApplicationInitializer接口，servlet3.0规范会在web容器启动时被自动扫描到并调用onStartup方法，
 * 该方法会注册一个过滤器DelegatingFilterProxy，因此仅需实现一个AbstractSecurityWebApplicationInitializer的空类，
 * 就可以起到在web.xml中配置过滤器DelegatingFilterProxy方式起用Spring Security.
 */
public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {


    protected void beforeSpringSecurityFilterChain(ServletContext servletContext) {
        insertFilters(servletContext, new Filter[]{new OAuth2ClientContextFilter()});
    }

}
